{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c69814ee",
   "metadata": {},
   "source": [
    "## 本周学习目标\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f74d5f2",
   "metadata": {},
   "source": [
    "### 一. 从奇数中选择对应的时间节点\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "97ce0621",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 从python基础库（标准库中）找到datetime模块\n",
    "from datetime import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9cea73e3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2021, 9, 6, 11, 15, 2, 535667)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "eb640586",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "时间是奇数，时间在odds的数据中.\n"
     ]
    }
   ],
   "source": [
    "# 课本代码（项目一，从奇数中选择对应的时间节点）5\n",
    "\n",
    "from datetime import datetime\n",
    "\n",
    "odds =[1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"时间是奇数，时间在odds的数据中.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8dfbf203",
   "metadata": {},
   "source": [
    "### 二. 认识变量及赋值\n",
    "##### 变量定义的规则：\n",
    "- 变量名只能是 字母、数字或下划线 的任意组合 且 第一个字符不能为数字\n",
    "- 以下关键字不能声明为变量名: \n",
    "['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda','not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']\n",
    "\n",
    "例如：name = lvin  ———— 其中，name 为变量名，lvin 则为变量名name的值\n",
    "\n",
    "#### 变量的赋值\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "644af764",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-27T05:23:01.928961Z",
     "start_time": "2021-09-27T05:23:01.911958Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "lvin lvin\n",
      "What is the value of name2 now?\n"
     ]
    }
   ],
   "source": [
    "name = \"lvin\"\n",
    "\n",
    "name2 = name\n",
    "print(name,name2)\n",
    "\n",
    "name = \"Gu\"\n",
    "\n",
    "print(\"What is the value of name2 now?\")\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "82cc9069",
   "metadata": {},
   "source": [
    "#### 变量（数字，字符串，对象）\n",
    "\n",
    "##### 数字（Numbers）\n",
    "类型 \n",
    "- int 为 整数 ； float 为 浮点数 ；complex 为复数\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "249d0579",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-27T05:34:42.182107Z",
     "start_time": "2021-09-27T05:34:42.162160Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> 2 + 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "75aee4f1",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-27T05:34:57.777716Z",
     "start_time": "2021-09-27T05:34:57.760713Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.0"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(50 - 5*6) / 4"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "99e0be82",
   "metadata": {},
   "source": [
    "##### 字符串（Strings）\n",
    "\n",
    "表示\n",
    "- 单引号 '...' 或双引号 \"...\"\n",
    "-  \\ 可用于转义引号"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "52b56cf4",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-27T05:38:57.932764Z",
     "start_time": "2021-09-27T05:38:57.918250Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"dosen't\""
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"dosen't\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "a89179b9",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-27T05:40:05.713572Z",
     "start_time": "2021-09-27T05:40:05.695551Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'doesn\\'t'  # \\ 避免重复三个'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5d0921f4",
   "metadata": {},
   "source": [
    "### 三. if else\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "a87dc3f8",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-27T05:49:22.356397Z",
     "start_time": "2021-09-27T05:49:22.347395Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "no\n"
     ]
    }
   ],
   "source": [
    "a = 3\n",
    "if a<1 :\n",
    "    print(\"ok\")\n",
    "else:\n",
    "    print(\"no\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "c704ed1a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-27T06:02:53.299200Z",
     "start_time": "2021-09-27T06:02:53.279213Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Work, work, work.\n"
     ]
    }
   ],
   "source": [
    "# if elif 的应用\n",
    "import time\n",
    "today = time.strftime(\"%a\")\n",
    "if today == \"Saturday\":\n",
    "    print(\"Party!\")\n",
    "elif today == \"Sunday\":\n",
    "    if condition == \"Headache\":\n",
    "        print(\"Recover, then rest.\")\n",
    "    else:\n",
    "        print(\"Rest.\")\n",
    "else:\n",
    "    print(\"Work, work, work.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "007170f0",
   "metadata": {},
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ac090c2c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
